Item path

Hello Forums,

is there any script to find the path for every item ,in a separate attribute , example :functional architecture/Assembly

 

It_1 1 General Features path
It_2 1.1 functional architecture  
It_3 1.1.1 Assembly  
it_4 here comes text functional architecture/Assembly

 

have anyone idea , thank you

 

best regards,

Neven


Control17 - Tue Nov 21 04:16:10 EST 2017

Re: Item path
Mike.Scharnow - Tue Nov 21 05:40:57 EST 2017

Hi Neven,

please explain, what "path" means to you. It does not look like a project / folder structure, perhaps something with chapters?

Re: Item path
Control17 - Tue Nov 21 05:56:31 EST 2017

Mike.Scharnow - Tue Nov 21 05:40:57 EST 2017

Hi Neven,

please explain, what "path" means to you. It does not look like a project / folder structure, perhaps something with chapters?

Hello Mike,

yes I mean the chapter path!

 

thank u

Neven

Re: Item path
Mike.Scharnow - Tue Nov 21 07:59:23 EST 2017

Control17 - Tue Nov 21 05:56:31 EST 2017

Hello Mike,

yes I mean the chapter path!

 

thank u

Neven

In the following doors structure

 

1. introduction
(object heading)
     
2. requirements
(object heading)
     
  2.1 technical requirements
(object heading)
   
    2.1.1 Assembly
(object heading)
 
      2.1.1-01 this is a requirement
(object text)

 

object "this is a requirement" has a "parent" object "assembly" etc. This object can be retrieved with the function "Object parent(object)" For object "requirements", the parent function returns null. . So, in your script, if you have a requirement, you can create a "while" loop that goes up the hiererchy and for each found parent you remember its Object Heading and concatenate all headings with a "/"

 

Re: Item path
Control17 - Tue Nov 21 08:35:28 EST 2017

Mike.Scharnow - Tue Nov 21 07:59:23 EST 2017

In the following doors structure

 

1. introduction
(object heading)
     
2. requirements
(object heading)
     
  2.1 technical requirements
(object heading)
   
    2.1.1 Assembly
(object heading)
 
      2.1.1-01 this is a requirement
(object text)

 

object "this is a requirement" has a "parent" object "assembly" etc. This object can be retrieved with the function "Object parent(object)" For object "requirements", the parent function returns null. . So, in your script, if you have a requirement, you can create a "while" loop that goes up the hiererchy and for each found parent you remember its Object Heading and concatenate all headings with a "/"

 

my code

pragma runLim, 0
Module m = current
Object o = current 
Object po  = parent o 
filtering off

for o in m do {
 stirng a = o."Object Heading"
 string b = o."Object Text" 
 string d = o."path"
 while (!null b ) {
    d = ???????
 
 }
 }

how can i get the d ?

 

 

Re: Item path
pommCannelle - Tue Nov 21 08:38:15 EST 2017

Mike.Scharnow - Tue Nov 21 07:59:23 EST 2017

In the following doors structure

 

1. introduction
(object heading)
     
2. requirements
(object heading)
     
  2.1 technical requirements
(object heading)
   
    2.1.1 Assembly
(object heading)
 
      2.1.1-01 this is a requirement
(object text)

 

object "this is a requirement" has a "parent" object "assembly" etc. This object can be retrieved with the function "Object parent(object)" For object "requirements", the parent function returns null. . So, in your script, if you have a requirement, you can create a "while" loop that goes up the hiererchy and for each found parent you remember its Object Heading and concatenate all headings with a "/"

 

string get_heading(Object o){
    if ( o."object heading""" == "" ) return "Not a title !"
    return o."object heading" ""
}

string get_path(Object o){
    if (level(o) == 1 ) return get_heading(o)
    if (o."object heading""" != "" ) return get_path(parent o) "/" get_heading(o)
    return get_path(parent o)
}

Have fun ;)

 

Re: Item path
Control17 - Wed Nov 22 05:59:40 EST 2017

pommCannelle - Tue Nov 21 08:38:15 EST 2017

string get_heading(Object o){
    if ( o."object heading""" == "" ) return "Not a title !"
    return o."object heading" ""
}

string get_path(Object o){
    if (level(o) == 1 ) return get_heading(o)
    if (o."object heading""" != "" ) return get_path(parent o) "/" get_heading(o)
    return get_path(parent o)
}

Have fun ;)

 

Hello ,

thank u for your reply , but I did not understand the function string with get

code

pragma runLim, 0
Module m = current
Object o = current 
Object po  = parent o 
filtering off

for o in m do {
 stirng a = o."Object Heading"
 string b = o."Object Text" 
 string d = o."path"
 while (!null b ) {
    d = get_path (o)
 
string get_heading(Object o){
    if ( o."object heading""" == "" ) return "Not a title !"
    return o."object heading" ""
}

string get_path(Object o){
    if (level(o) == 1 ) return get_heading(o)
    if (o."object heading""" != "" ) return get_path(parent o) "/" get_heading(o)
    return get_path(parent o)
}
 
 }
 }

my code dose not work , do u know why ?

 

thank u

Neven

Re: Item path
Mike.Scharnow - Wed Nov 22 06:24:23 EST 2017

Control17 - Wed Nov 22 05:59:40 EST 2017

Hello ,

thank u for your reply , but I did not understand the function string with get

code

pragma runLim, 0
Module m = current
Object o = current 
Object po  = parent o 
filtering off

for o in m do {
 stirng a = o."Object Heading"
 string b = o."Object Text" 
 string d = o."path"
 while (!null b ) {
    d = get_path (o)
 
string get_heading(Object o){
    if ( o."object heading""" == "" ) return "Not a title !"
    return o."object heading" ""
}

string get_path(Object o){
    if (level(o) == 1 ) return get_heading(o)
    if (o."object heading""" != "" ) return get_path(parent o) "/" get_heading(o)
    return get_path(parent o)
}
 
 }
 }

my code dose not work , do u know why ?

 

thank u

Neven

looks like you just pasted together the code of several tips without having a basic script in which to include the information.

First you make clear to yourself what to do with the information. Do  you want to fill a DXL attribute? Do you want to fill a DXL layout column? do you want to fill a real (persistent) attribute? When and how shall your script run?

 

- decide whether you want to get the path of one object (Object o = current) or whether you want a loop over all objects (for o in m do). Both at the same time does not make sense.

- If you want to fill a persistent attribute called "path", you surely do not want to write ->string d = o."path"<-, but you want to fill the attribute like ->o."path" = d<-, after d contains the correct information. 

- Then, if you really copy/pasted the code and did not type it from DXL to this web site, you should get rid of your syntax errors first (e.g. "stirng" instead of "string")

- then, you do not want to use a while  loop, you need an if statement! Look up the difference in your guide how to program, otherwise you have an endless loop.

- then, function definitions should not be made inside a loop or in the middle of code. 

 

Re: Item path
Control17 - Wed Nov 22 07:35:13 EST 2017

Mike.Scharnow - Wed Nov 22 06:24:23 EST 2017

looks like you just pasted together the code of several tips without having a basic script in which to include the information.

First you make clear to yourself what to do with the information. Do  you want to fill a DXL attribute? Do you want to fill a DXL layout column? do you want to fill a real (persistent) attribute? When and how shall your script run?

 

- decide whether you want to get the path of one object (Object o = current) or whether you want a loop over all objects (for o in m do). Both at the same time does not make sense.

- If you want to fill a persistent attribute called "path", you surely do not want to write ->string d = o."path"<-, but you want to fill the attribute like ->o."path" = d<-, after d contains the correct information. 

- Then, if you really copy/pasted the code and did not type it from DXL to this web site, you should get rid of your syntax errors first (e.g. "stirng" instead of "string")

- then, you do not want to use a while  loop, you need an if statement! Look up the difference in your guide how to program, otherwise you have an endless loop.

- then, function definitions should not be made inside a loop or in the middle of code. 

 

thank u , with your advise I get my code .

I really appreciate your help !

 

Best regards,

Neven